﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

namespace EventFlowLibrary.LevelComponents
{
    /// <summary>
    /// Model positioning info
    /// TOOD move elsewhere?
    /// </summary>
    public struct ModelVariables
    {
        public Vector3 position;
        public Vector3 rotation;
        public Vector3 scale;

        public ModelVariables(Vector3 _position, Vector3 _rotation, Vector3 _scale)
        {
            position = _position;
            rotation = _rotation;
            scale = _scale;
        }
    }

    public class LoadVariables
    {
        /// <summary>
        /// When the file we are loading was saved.
        /// </summary>
        public DateTime saved;
        /// <summary>
        /// How long the saved game was played before being saved.
        /// </summary>
        public double timePlayed;
        /// <summary>
        /// The XML level to load.
        /// </summary>
        public string level;
        /// <summary>
        /// Character position for the save we're reading.
        /// </summary>
        public Vector3 position;
        /// <summary>
        /// Character orientation for the save we're reading.
        /// </summary>
        public Quaternion orientation;
        /// <summary>
        /// Camera pitch for the save we're reading
        /// </summary>
        public float cameraPitch;
        /// <summary>
        /// Camera yaw for the save we're reading
        /// </summary>
        public float cameraYaw;
        /// <summary>
        /// Some camera modes separate the camera yaw and character orientation. Track our character y orienation if that is the case.
        /// </summary>
        public float totalRotationY;
        /// <summary>
        /// The game states whose values we track
        /// </summary>
        public Dictionary<string, string> gameState;
        /// <summary>
        /// Track our models, so that any that have moved can be placed back where they were.
        /// First dictionary is the level, the second is the model ID - the combination is unique.
        /// </summary>
        public Dictionary<string, Dictionary<string, ModelVariables>> modelPositioning;
    }

    public class GameSettings
    {
        /// <summary>
        /// The <c>Microsoft.Xna.Framework.Media.MediaPlayer</c>.Volume setting, from 0.0f-1.0f.
        /// </summary>
        public float MusicVolume
        {
            get { return musicVolume; }
            set
            {
                musicVolume = value;
                Microsoft.Xna.Framework.Media.MediaPlayer.Volume = value;
            }
        }
        private float musicVolume;
        /// <summary>
        /// The 0.0f-1.0f sound effect master volume read from the settings.
        /// </summary>
        public float SoundEffectVolume
        {
            get { return soundEffectVolume; }
            set
            {
                soundEffectVolume = value;
                SoundEffect.MasterVolume = value;
            }
        }
        private float soundEffectVolume;
        /// <summary>
        /// Whether the controller stick is inverted.
        /// </summary>
        public bool Inverted;
        /// <summary>
        /// Whether the camera is bobbing or not.
        /// </summary>
        public bool CameraBobEnabled = true;
    }
}
